package com.cosina.game.crystallight.model.crystal;

import com.cosina.game.crystallight.engine.BattleEngine;
import com.cosina.game.crystallight.engine.util.UpCount;
import com.cosina.game.crystallight.model.enemy.Enemy;

public class Weapon {
	public int attack;
	public int range;
	public float rangePercent;
	public float speedPercent;
	public UpCount attackCount;
	
	private boolean reload;
	
	private Crystal belong;
	public Weapon(Crystal belong,int attack){
		this.belong = belong;
		this.attack = attack;
		this.reload = true;
		this.range = UpgradeSystem.DEFAULT_RANGE;
		this.attackCount = new UpCount(UpgradeSystem.DEFAULT_SPEED);
	}
	
	public boolean canAttack(){
		return reload;
	}
	
	public void attack(Tower tower,Enemy enemy){
		reload = false;
		BattleEngine.psManager.createPs(tower, enemy, belong);
	}
	
	public void tryReload(){
		if(false == reload){
			if(attackCount.upToAlram()){
				reload = true;
			}
		}
	}

	public int getAttack() {
		return attack;
	}
}
